import request from '@/utils/request'
import qs from 'qs'

export function queryById(pkId) {
  return request({
    url: '/api/script/convert/target/list/' + pkId,
    method: 'get'
  })
}

export function findLatestSuccess(params) {
  return request({
    url: '/api/script/convert/target/list/latestSuccess' + '?' + qs.stringify(params, { indices: false }),
    method: 'get'
  })
}

export function queryContentById(crunPkId, histPkId, convertFileName) {
  return request({
    url: '/api/script/convert/target/list/' + crunPkId + '/' + histPkId + '?convertFileName=' + convertFileName,
    method: 'get'
  })
}

export function updateFileContent(data) {
  return request({
    url: '/api/script/convert/target/list/update/file/content',
    method: 'put',
    data: data
  })
}

export function reverify(pkId) {
  return request({
    url: '/api/script/convert/target/list/reverify/' + pkId,
    method: 'put'
  })
}

export function downloadTemplate() {
  return request({
    url: '/api/script/convert/target/list/template',
    method: 'get'
  })
}

export default {
  queryById,
  findLatestSuccess,
  queryContentById,
  updateFileContent,
  reverify,
  downloadTemplate
}
